#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: comparision.sh
# Description: 
#  syntax:
#   expression { actions; }   
#   (expr1) && (expr2)
#   (expr2) || (expr2)
# Edit History: 
#   2010-12-23    File created.
#========================================================================
# Operator              Description
# <						Less than
# >						Greater than
# <=					Less than or equal to
# >=					Greater than or equal to
# ==					Equal to
# !=					Not equal to
# value ~ / pattern/	True if value matches pattern
# value !~ / pattern/   True if value does not match pattern
# (expr1) && (expr2)
# (expr2) || (expr2)

#next用來跳過下一個expression, 因為<=75成立就不會>75 (用來提升效率)
awk '
$3 <= 75 { printf "%s\t%s\n",$0,"REORDER" ;  next ;} 
$3 > 75 { print $0 ; }
' fruit_prices.txt

awk '
($2 ~ /^\$[1-9][0-9]*\.[0-9][0-9]$/) && ($3 < 75) {
printf "%s\t%s\t%s\n",$0,"*","REORDER" ;
}
' fruit_prices.txt ;
